module.exports = function($scope, $resource, toaster, $modalInstance, what, obj){

	$scope.obj = {};
	if(what == 'edit') {
		$scope.obj = obj;
	}

	//保存
	$scope.save = function(){

		if(!$scope.obj.reply_type_name){
			toaster.warning({title: '', body: '请填写问题类别名称.'});
			return false;
		}
		if(!$scope.obj.reply_type_content){
			toaster.warning({title: '', body: '请填写问题类别描述.'});
			return false;
		}

		$resource('/api/as/goc/infodiffusion/createquestiontype', {}, {}).save($scope.obj, function(res){
            if (res.errcode === 0) {
                toaster.success({title: '', body: '保存成功'});
                $modalInstance.close();
            } else {
                toaster.error({title: '', body: res.errmsg});
            }
        });
	}

	//取消
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
	}
	
};